Skip to content

feat: event debugging (WIP) #1726

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

mdjastrzebski
Copy link
Member

@mdjastrzebski mdjastrzebski commented Jan 7, 2025

Summary

Resolves #1717
Resolves #1718

Introduces (event) debugging mode that outputs information about event handles not being called due to disabled state, etc.

Details

Enabling: configure({ debug: true }). Cannot be configured on render as fireEvent and userEvent are independent modules, not returns from render.

Fire Event:

  • logs warnings when event handler was found but disabled:
  • logs warning when no event handler was invoked for given fireEvent call.

User Event:

  • logs debug for events that have missing event handlers.

To Do

  • User Event: log warning if no event at all has been called for given userEvent call.
  • Fire Event & User Event: consider logging debug for matches/called event handlers.

Test plan

Copy link

codecov bot commented Jan 7, 2025

Codecov Report

Attention: Patch coverage is 86.17886% with 17 lines in your changes missing coverage. Please review.

Project coverage is 95.47%. Comparing base (17ccd9e) to head (95845da).

Files with missing lines Patch % Lines
src/helpers/logger.ts 59.25% 11 Missing ⚠️
src/fire-event.ts 86.36% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1726      +/-   ##
==========================================
- Coverage   95.50%   95.47%   -0.04%     
==========================================
  Files          92       92              
  Lines        5139     5235      +96     
  Branches      563      901     +338     
==========================================
+ Hits         4908     4998      +90     
- Misses        231      237       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mdjastrzebski mdjastrzebski force-pushed the feat/event-debugging branch 3 times, most recently from ec51869 to 81a631b Compare January 13, 2025 11:05
@mdjastrzebski
Copy link
Member Author

Could you share your feedback on this potential new feature @pierrezimmermannbam @MattAgn @AugustinLF

@@ -19,6 +19,11 @@ export type Config = {
* Otherwise `render` will default to concurrent rendering.
*/
concurrentRoot: boolean;

/**
* Verbose logging for the library.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would add what it helps log : user event and fire event issues (for now)

@@ -30,6 +35,7 @@ const defaultConfig: Config = {
asyncUtilTimeout: 1000,
defaultIncludeHiddenElements: false,
concurrentRoot: true,
debug: false,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo true is a good default because otherwise i fear not many people will hear about it and remember to turn it on
do you see more advantages with false as default ?

@MattAgn
Copy link
Collaborator

MattAgn commented Aug 18, 2025

This is gonna be so helpful to debug! ✅

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UX: feedback when event could not be triggered due to disabled state, etc Log when fireEvent fails to fire an event
2 participants